#define _CRT_SECURE_NO_WARNINGS
#pragma warning(disable:6031)
#include<stdio.h>
int majorityElement(int* nums, int numsSize) {
    int i = 0;
    for (i = 0; i < numsSize; i++)
    {
        int count = 1;
        for (int j = 0; j < numsSize; j++)
        {
            if (i != j && nums[i] == nums[j])
            {
                count++;
            }
        }
        if (count > numsSize / 2)
        {
            break;
        }
    }
    return nums[i];
}
int main()
{
    int nums[] = { 2,2,1,1,2,2};
    int numsSize = sizeof(nums) / sizeof(nums[0]);
    printf("%d", majorityElement(nums, numsSize));
	return 0;
}
